#ifndef __layer_uart__
#define __layer_uart__
/*
	UART Layer

	This module defines the Uart layer for both Atmega1280 and Atmega128 MCU's

	Use the function hooks to utilise all the advanved features
*/
#include "globals.h"
#include "bikirom-ints.h"

// MACRO's
typedef void (*_uart_recieve)(unsigned char c, unsigned short nLength);

// Initialisation Functions
uint8_t		uart_init		(uint8_t nUart, unsigned long nBaud, _uart_recieve uart_recieve,
								 unsigned char* uchTxBuffer, u16 nTxLength,
								 unsigned char* uchRxBuffer, u16 nRxLength,
								 enum _eExtInts eRtsInt);
void		uart_bytes_rx	(uint8_t nUart,	u16 nBytes);	// Number of bytes to notify on

// Uart Functions
void		uart_enable_tx				(uint8_t nUart, uint8_t bEnable);
void		uart_enable_rx				(uint8_t nUart, uint8_t bEnable);
void		uart_send_byte_unbuffered	(uint8_t nUart, uint8_t data);
short		uart_get_byte				(uint8_t nUart);
// Buffer Functions

// Transmit Functions
void	uart_send_byte			(uint8_t nUart, uint8_t data);
uint8_t	uart_send_buffer		(uint8_t nUart, unsigned char* buffer, u16 nBytes);
void	uart_append_buffer_tx	(uint8_t nUart, unsigned char* buffer, u16 nBytes);
void	uart_flush_tx_buffer	(uint8_t nUart);

// Recieve Functions
void	uart_append_buffer_rx	(uint8_t nUart, unsigned char* buffer, u16 nBytes);
void	uart_flush_rx_buffer	(uint8_t nUart);

#endif
